// HSS.Logging.LogEntry.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       LogEntry.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Logging
{
	#region Using Directives
	using System.Diagnostics;
	#endregion

	#region LogEntry
	/// <summary>
	/// A Log Entry
	/// </summary>
	public sealed class LogEntry
	{
		#region Constructor
		/// <summary>
		/// Default ctor
		/// </summary>
		public LogEntry()
		{
			this.EventId = 0;
			this.CreatedDate = System.DateTime.MinValue;
		}
		/// <summary>
		/// Constructs a log entry
		/// </summary>
		/// <param name="message">The message to write.</param>
		/// <param name="userName">The name of the person or program writing this message.</param>
		/// <param name="category">The Category of this entry.</param>
		/// <param name="xmlString">The Xml String to attach to this entry.</param>
		/// <param name="applicationName">The name of the application this entry is associated with.</param>
		/// <param name="referenceNumber">A reference number to associate with the entry.</param>
		/// <param name="createdDate">The date and time of the entry.</param>
		/// <param name="eventType">The event type for the entry.</param>
		public LogEntry(string message, string userName, string category, string xmlString, string applicationName, string referenceNumber, System.DateTime createdDate, EventLogEntryType eventType)
		{
			this.EventId = 0;
			this.Message = message;
			this.User = userName;
			this.Category = category;
			this.XmlString = xmlString;
			this.ApplicationName = applicationName;
			this.ReferenceNumber = referenceNumber;
			this.CreatedDate = createdDate;
			this.EventType = eventType;
		}
		/// <summary>
		/// Constructs a log entry
		/// </summary>
		/// <param name="userName">The name of the person or program writing this message.</param>
		/// <param name="category">The Category of this entry.</param>
		/// <param name="xmlString">The Xml String to attach to this entry.</param>
		/// <param name="applicationName">The name of the application this entry is associated with.</param>
		/// <param name="referenceNumber">A reference number to associate with the entry.</param>
		/// <param name="createdDate">The date and time of the entry.</param>
		/// <param name="eventType">The event type for the entry.</param>
		public LogEntry(string userName, string category, string xmlString, string applicationName, string referenceNumber, System.DateTime createdDate, EventLogEntryType eventType)
		{
			this.EventId = 0;
			this.Message = string.Empty;
			this.User = userName;
			this.Category = category;
			this.XmlString = xmlString;
			this.ApplicationName = applicationName;
			this.ReferenceNumber = referenceNumber;
			this.CreatedDate = createdDate;
			this.EventType = eventType;
		}
		/// <summary>
		/// Constructs a log entry
		/// </summary>
		/// <param name="eventId">Id of this Entry</param>
		/// <param name="message">The message to write.</param>
		/// <param name="userName">The name of the person or program writing this message.</param>
		/// <param name="category">The Category of this entry.</param>
		/// <param name="xmlString">The Xml String to attach to this entry.</param>
		/// <param name="applicationName">The name of the application this entry is associated with.</param>
		/// <param name="referenceNumber">A reference number to associate with the entry.</param>
		/// <param name="createdDate">The date and time of the entry.</param>
		/// <param name="eventType">The event type for the entry.</param>
		public LogEntry(int eventId, string message, string userName, string category, string xmlString, string applicationName, string referenceNumber, System.DateTime createdDate, EventLogEntryType eventType)
		{
			this.EventId = eventId;
			this.Message = message;
			this.User = userName;
			this.Category = category;
			this.XmlString = xmlString;
			this.ApplicationName = applicationName;
			this.ReferenceNumber = referenceNumber;
			this.CreatedDate = createdDate;
			this.EventType = eventType;
		}
		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the Id of this Entry
		/// </summary>
		public int EventId
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Type of this entry
		/// </summary>			
		public EventLogEntryType EventType
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the event message
		/// </summary>
		public string Message
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Category of this entry
		/// </summary>
		public string Category
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the name of the application that this entry is associated with.
		/// </summary>
		public string ApplicationName
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Reference Number for an Item being processed associated with this entry
		/// </summary>
		public string ReferenceNumber
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Xml associated with this entry
		/// </summary>
		public string XmlString
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the user associated with this entry
		/// </summary>
		public string User
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the created date.
		/// </summary>
		public System.DateTime CreatedDate { get; set; }
		/// <summary>
		/// Gets or sets the Id of an associated Attachment
		/// </summary>
		public int AttachmentId
		{
			get;
			set;
		}
		#endregion

		#region Methods
		/// <summary>
		/// Update the Entry
		/// </summary>
		/// <param name="message">The event message</param>
		/// <param name="category">The Category of this entry</param>
		/// <param name="referenceNumber">The Reference Number for an Item being processed associated with this entry</param>
		/// <param name="userName">The user associated with this entry</param>
		/// <param name="xmlString">The Xml associated with this entry</param>
		/// <param name="eventType">The Type of this entry</param>
		public void Update(string message, string category, string referenceNumber, string userName, string xmlString, EventLogEntryType eventType)
		{
			this.Message = message;
			this.User = userName;
			this.Category = category;
			this.XmlString = xmlString;
			this.ReferenceNumber = referenceNumber;
			this.EventType = eventType;
		}
		/// <summary>
		/// Return the EventId and Message for this instance
		/// </summary>
		/// <returns>A string containing the EventId and Message for this instance</returns>
		public override string ToString()
		{
			return this.EventId.ToString() + ":" + this.Message;
		}
		#endregion
	}
	#endregion
}